<!--
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 14:41:20
 * @LastEditTime: 2023-07-31 10:13:46
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description:   :gridOps="gridOptions" inventory
-->
<template>
  <sc-VxeTable ref="xGrid" :gridEvts="gridEvents" :tablecode="'market_order_info'" :url="api.market.order.list"
    :params="{ state_id: 3 }">
  </sc-VxeTable>

  <SaveDialog v-if="dialog.save" ref="saveDialog" @success="handleSuccess" @closed="dialog.save = false"></SaveDialog>

  <ProList v-if="dialog.proList" ref="proList" @success="handleSuccess" @closed="dialog.proList = false"></ProList>
</template>
<script>
export default {
  name: "market_order_self",
};
</script>
<script setup>
import api from "@/api";
// import { useRouter } from "vue-router";
import { ref, nextTick } from "vue";
// , onMounted, reactive, ref
// const router = useRouter();
import SaveDialog from "./saveself";
import ProList from "./proList";
const dialog = ref({
  save: false,
  proList: false,
});

const xGrid = ref({});
const saveDialog = ref({});
const proList = ref({});
const handleSuccess = () => {
  xGrid.value.refresh();
};

const gridEvents = {
  cellDblclick: function ({ row }) {
    gridEvents.edit({ button: { selectRecords: [row] } });
  },
  add: function () {
    dialog.value.save = true;
    nextTick(() => {
      saveDialog.value.open();
    });
  },
  edit: function ({ button }) {
    dialog.value.save = true;
    nextTick(() => {
      saveDialog.value.setData(button.selectRecords[0]);
      saveDialog.value.open("edit");
    });
  },
  proList: function ({ button }) {
    dialog.value.proList = true;
    nextTick(() => {
      proList.value.setData({ "pro_plan.order.main.id": button.selectRecords[0].id });
      proList.value.open("edit");
    });
  },
};
</script>
